﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace FYP14
{
    public partial class ViewAppoinments : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                SetInitialRow();
            }
        }

        private void SetInitialRow()
        {
            DataTable dt = BAL.GetAllAppointments();
            ViewState["Savedt"] = dt;
            gvPurchase.DataSource = dt;
            gvPurchase.DataBind();
        }

        protected void gvPurchase_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {

            }
        }

        protected void lnkRemove_Click(object sender, EventArgs e)
        {
            ImageButton lb = (ImageButton)sender;
            Response.Redirect("AddAppointment.aspx?ID=" + lb.CommandArgument);
        }

        protected void gvPurchase_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            gvPurchase.PageIndex = e.NewPageIndex;
            DataTable dt = new DataTable();
            if (ViewState["Savedt"] != null)
            {
                dt = (DataTable)ViewState["Savedt"];
            }
            else
            {
                dt = BAL.GetAllAppointments();
                ViewState["Savedt"] = dt;
            }
            gvPurchase.DataSource = dt;
            gvPurchase.DataBind();
        }
    }
}